package TXPathFinder;

/**
*       \class	ChooseColor
*	\brief	Panel qui permet de choisir la couleur de l'avatar
**/
public class ChooseColor extends javax.swing.JDialog
{
    private Viewer viewer;
    
    /**
    *	\brief	Constructeur
    *   \param parent Le père de la fenêtre de dialogue
    *   \param modal Définit si la fenêtre de dialogue est modal ou non
    *   \param view Le Viewer3D
    **/
    public ChooseColor(java.awt.Frame parent, boolean modal, Viewer view) {
        super(parent, modal);
        viewer = view;
        initComponents();
    }

    /**
     *	\brief	Crée et initialise tout les composants de l'interface utilisatuer
    **/
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jColorChooser1 = new javax.swing.JColorChooser();
        buttonValide = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        buttonValide.setText("Valider ");
        buttonValide.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonValideActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(buttonValide, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
                    .addComponent(jColorChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jColorChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonValide)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     *	\brief	Action sur le bouton valider
     * \param evt Evenement
    **/
    private void buttonValideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonValideActionPerformed
        viewer.setCurrentColor(jColorChooser1.getColor());
        this.dispose();
    }//GEN-LAST:event_buttonValideActionPerformed

    /**
     *	\brief	Main de la JDialog
     * \param args[] Argument du main
    **/
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ChooseColor dialog = new ChooseColor(new javax.swing.JFrame(), true, null);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonValide;
    private javax.swing.JColorChooser jColorChooser1;
    // End of variables declaration//GEN-END:variables

}
